using System.Numerics;
using TTEngine.Graphics;
using TTEngine.Resource;
using TTEngine.TTMath;

namespace TTEngine.Framework.UI
{
    public class UIScale9 : UIBaseElement
    {
        private PackedTextureSpriteScale9 _scale9;

        public UIScale9(PackedTextureSpriteScale9 scale9 = null)
        {
            _scale9 = scale9;
            if (scale9 != null)
            {
                LocalRect.SetByRect(new Rectangle(0, 0, scale9.Info.PixelWidth, scale9.Info.PixelHeight));
            }
            else
            {
                LocalRect.SetByRect(new Rectangle(0, 0, 128, 128));
            }
        }

        public float scale=1.0f;
        public override void OnRender(UICanvas canvas)
        {
            if (_scale9 != null)
            {
                canvas.Batcher.GetPackedTextureBatcher().DrawSpriteScale9(_scale9, scale, GetWorldRect(), 0, _colorFinal);
            }
        }
    }
} 